package com.sina.shop.controller.async;

import com.sina.shop.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created with IntelliJ IDEA.
 * Description: 异步线程池测试
 * 段浩杰   2018-01-08-10:23
 */
@Controller
@RequestMapping("async")
public class AsyncController extends BaseController {

    @Autowired
    @Qualifier("asyncService")
    private AsyncService asyncService;

    @RequestMapping("asyncMethod")
    @ResponseBody
    public String AsyncMethod(String id) {

        Long beginTime = System.currentTimeMillis();

        asyncService.Task1(id);
        asyncService.Task2(id);
        asyncService.Task3(id);

        Long endTime = System.currentTimeMillis();

        LOG.info("sum time:{}", endTime - beginTime);
        return "ok";
    }
}
